<template>
  <div class="app-container">
    <div class="filter-container">
      <el-button
        v-waves
        class="el-button filter-item el-button--primary el-button--medium"
        type="primary"
        @click="handleFilter('')"
      >全部({{ carTotal.total }})</el-button>
      <el-button
        v-waves
        class="el-button filter-item el-button--primary el-button--medium"
        type="primary"
        @click="handleFilter(0)"
      >在线({{ carTotal.chauffeurOnline }})</el-button>
      <el-button
        v-waves
        value="1"
        class="el-button filter-item el-button--primary el-button--medium"
        type="primary"
        @click="handleFilter(1)"
      >忙碌({{ carTotal.chauffeurBusy }})</el-button>
      <el-button
        v-waves
        class="el-button filter-item el-button--primary el-button--medium"
        type="danger"
        @click="handleFilter(-1)"
      >停用数({{ carTotal.chauffeurStopped }})</el-button>
    </div>
    <div class="filter-container" style="padding: 16px 0;">
      <!-- <el-input v-model="listQuery.driverName" placeholder="司机" style="width: 200px;" class="filter-item el-input--medium" @keyup.enter.native="handleFilter" />
      <el-input v-model="listQuery.ownerName" placeholder="货主" style="width: 200px;" class="filter-item el-input--medium" @keyup.enter.native="handleFilter" />-->

      <el-input
        v-model="search.number"
        placeholder="身份证号码"
        style="width: 200px;"
        class="filter-item el-input--medium"
        @keyup.enter.native="searchList"
      />
      <!-- <el-select v-model="listQuery.importance" placeholder="Imp" clearable style="width: 90px" class="filter-item">
        <el-option v-for="item in importanceOptions" :key="item" :label="item" :value="item" />
      </el-select>
      <el-select v-model="listQuery.type" placeholder="Type" clearable class="filter-item" style="width: 130px">
        <el-option v-for="item in calendarTypeOptions" :key="item.key" :label="item.display_name+'('+item.key+')'" :value="item.key" />
      </el-select>
      <el-select v-model="listQuery.sort" style="width: 140px" class="filter-item" @change="handleFilter">
        <el-option v-for="item in sortOptions" :key="item.key" :label="item.label" :value="item.key" />
      </el-select>-->
      <el-button
        v-waves
        class="el-button filter-item el-button--primary el-button--medium"
        type="primary"
        icon="el-icon-search"
        @click="searchList"
      >搜索</el-button>
      <el-button
        class="filter-item"
        style="margin-left: 10px;"
        type="primary"
        icon="el-icon-edit"
        @click="handleCreate"
      >新增</el-button>
      <!-- <el-button v-waves :loading="downloadLoading" class="filter-item" type="primary" icon="el-icon-download" @click="handleDownload">
        Export
      </el-button>
      <el-checkbox v-model="showReviewer" class="filter-item" style="margin-left:15px;" @change="tableKey=tableKey+1">
        reviewer
      </el-checkbox>-->
    </div>

    <el-table
      :key="tableKey"
      v-loading="listLoading"
      :data="list"
      border
      fit
      highlight-current-row
      style="width: 100%;"
      @sort-change="sortChange"
    >
      <el-table-column label="编号" width="150" align="center">
        <template slot-scope="{row}">
          <span>{{ row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column label="昵称" align="center">
        <template slot-scope="{row}">
          <span>{{ row.nickname }}</span>
          <!-- <el-tag>{{ row.ownerName  }}</el-tag> -->
        </template>
      </el-table-column>
      <el-table-column label="真实姓名" align="center">
        <template slot-scope="{row}">
          <span>{{ row.realName }}</span>
          <!-- <el-tag>{{ row.ownerName  }}</el-tag> -->
        </template>
      </el-table-column>
      <el-table-column label="电话" align="center" width="110">
        <template slot-scope="{row}">
          <span>{{ row.phone }}</span>
        </template>
      </el-table-column>
      <el-table-column label="地址" align="center">
        <template slot-scope="{row}">
          <span>{{ row.chauffeurAddress }}</span>
          <!-- <el-tag>{{ row.ownerName  }}</el-tag> -->
        </template>
      </el-table-column>
      <el-table-column label="身份证号码" align="center" width="185">
        <template slot-scope="{row}">
          <span>{{ row.idCardNumber }}</span>
          <!-- <el-tag>{{ row.ownerName  }}</el-tag> -->
        </template>
      </el-table-column>
      <el-table-column label="身份证" align="center" width="130">
        <template slot-scope="{row}">
          <el-popover v-if="row.frontImg" placement="top-start" trigger="click">
            <!--trigger属性值：hover、click、focus 和 manual-->
            <a :href="row.frontImg" target="_blank" title="查看最大化图片">
              <img :src="row.frontImg" style="width: 100%;height: 100%">
            </a>
            <img
              v-if="row.frontImg"
              slot="reference"
              :src="row.frontImg"
              class="carImg"
              style="cursor:pointer"
            >
          </el-popover>
          <p v-else>未上传</p>

          <!-- <img :src="row.intoImg" alt class="carImg"> -->
        </template>
      </el-table-column>
      <el-table-column label="公司认证" align="center" width="130">
        <template slot-scope="{row}">
          <el-popover v-if="row.intoImg" placement="top-start" trigger="click">
            <!--trigger属性值：hover、click、focus 和 manual-->
            <a :href="row.intoImg" target="_blank" title="查看最大化图片">
              <img :src="row.intoImg" style="width: 100%;height: 100%">
            </a>
            <img slot="reference" :src="row.intoImg" class="carImg" style="cursor:pointer">
          </el-popover>
          <p v-else>未上传</p>
        </template>
      </el-table-column>
      <el-table-column label="订单数" align="center">
        <template slot-scope="{row}">
          <span>{{ row.orderTotalNumber }}</span>
        </template>
      </el-table-column>

      <el-table-column label="好评率" align="center">
        <template slot-scope="{row}">
          <span>{{ row.goodCommentRate }}</span>
        </template>
      </el-table-column>

      <el-table-column label="推广数" align="center">
        <template slot-scope="{row}">
          <span>{{ row.vehicleVolume }}</span>
        </template>
      </el-table-column>

      <!-- <el-table-column v-if="showReviewer" label="Reviewer" width="110px" align="center">
        <template slot-scope="{row}">
          <span style="color:red;">{{ row.reviewer }}</span>
        </template>
      </el-table-column>
      <el-table-column label="Imp" width="80px">
        <template slot-scope="{row}">
          <svg-icon v-for="n in + row.importance" :key="n" icon-class="star" class="meta-item__icon" />
        </template>
      </el-table-column>
      <el-table-column label="Readings" align="center" width="95">
        <template slot-scope="{row}">
          <span v-if="row.pageviews" class="link-type" @click="handleFetchPv(row.pageviews)">{{ row.pageviews }}</span>
          <span v-else>0</span>
        </template>
      </el-table-column>
      <el-table-column label="Status" class-name="status-col" width="100">
        <template slot-scope="{row}">
          <el-tag :type="row.status | statusFilter">
            {{ row.status }}
          </el-tag>
        </template>
      </el-table-column>-->
      <el-table-column label="操作" width="220" align="center" class-name="small-padding fixed-width">
        <template slot-scope="{row}">
          <el-button size="mini" @click="openDetail(row.id)">详情</el-button>
          <!-- <el-button type="primary" size="mini" @click="handleUpdate(row)">
            编辑
          </el-button>
         <el-button v-if="row.status!='published'" size="mini" type="success" @click="handleModifyStatus(row,'published')">
            Publish
          </el-button>-->
          <el-button v-if="row.state!='-2'" size="mini" type="danger" @click="stopCar(row.id)">停用</el-button>
          <el-button v-if="row.state=='-2'" size="mini" type="success" @click="backCar(row.id)">恢复</el-button>
          <!-- <el-button v-if="row.state=='-2'" size="mini" type="danger" @click="deleteCar(row.id)">删除</el-button> -->
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="listQuery.pageNum"
      :limt.sync="listQuery.pageSize"
      @pagination="getList"
    />

    <el-dialog
      ref="drag-dialog"
      :visible.sync="dialogTableVisible"
      title="司机详情"
      label-width="70px"
      width="80%"
      top="10px"
    >
      <div>
        <table class="driverDetialTable">
          <tr>
            <td rowspan="6">
              <div
                style="width:100px;height:100px;border-radius: 100px;background-color: #409eff;overflow: hidden;"
              >
                <el-upload
                  class="avatar-uploader"
                  :action="UploadUrl()"
                  :headers="header"
                  :show-file-list="true"
                  :on-success="handleAvatarSuccess"
                  :before-upload="beforeAvatarUpload"
                >
                  <img v-if="driverData.headImg" :src="driverData.headImg" class="avatar">
                  <i v-else class="el-icon-plus avatar-uploader-icon" />
                </el-upload>
                <!-- <img :src="driverData.headImg" alt style="width:100px;"> -->
              </div>
              <input v-model="editDriver.nickname">
            </td>
            <td class="tableTitle">用户ID</td>
            <td>{{ driverData.id }}</td>
          </tr>
          <tr>
            <td class="tableTitle">身份</td>
            <td>{{ driverData.userType | usertype(driverData.userType) }}</td>
          </tr>
          <tr>
            <td class="tableTitle">联系电话</td>
            <td>
              <input v-model="editDriver.phone">
            </td>
          </tr>
          <tr>
            <td class="tableTitle">城市</td>
            <td>
              <!-- <input v-model="editDriver.address"> -->
              {{ driverData.address }}
            </td>
          </tr>
          <tr>
            <td class="tableTitle">注册时间</td>
            <td>{{ driverData.userCreateTime| parseTime('{y}-{m}-{d} {h}:{i}') }}</td>
          </tr>
          <tr>
            <td class="tableTitle">驾驶年限</td>
            <td>
              <input v-model="editDriver.driverAge">
            </td>
          </tr>
        </table>
      </div>
      <div>
        <div>
          <aside>统计信息</aside>
        </div>
        <el-table :data="driverTotalData">
          <el-table-column property="income" label="收入金额" width="150" />
          <el-table-column property="orderTotal" label="订单数" width="200" />
          <el-table-column property="commentTotal" label="被评价数" />
          <el-table-column property label="邀请人数" />
        </el-table>
      </div>
      <div>
        <div>
          <aside>身份认证信息</aside>
        </div>
        <el-collapse accordion>
          <el-collapse-item>
            <template slot="title">
              身份证 (
              <p v-if="driverData.idAuthState==1">已认证</p>
              <p v-else>未认证</p>)
            </template>
            <div style="display: flex;">
              <el-popover
                v-if="driverData.pictures.idCardImgB"
                placement="top-start"
                trigger="click"
              >
                <a :href="driverData.pictures.idCardImgB" target="_blank" title="查看最大化图片">
                  <img :src="driverData.pictures.idCardImgB" style="width: 100%;height: 100%">
                </a>
                <img
                  slot="reference"
                  :src="driverData.pictures.idCardImgB"
                  class="carImg"
                  style="cursor:pointer"
                >
              </el-popover>
              <el-upload
                class="upload-demo"
                :action="UploadUrl()"
                :headers="header"
                :show-file-list="false"
                :on-success="handleIdCardImgBSuccess"
                :before-upload="beforeAvatarUpload"
              >
                <el-button size="small" type="primary">点击上传</el-button>
              </el-upload>
            </div>
            <div style="display: flex;">
              <el-popover
                v-if="driverData.pictures.idCardImgF"
                placement="top-start"
                trigger="click"
              >
                <a :href="driverData.pictures.idCardImgF" target="_blank" title="查看最大化图片">
                  <img :src="driverData.pictures.idCardImgF" style="width: 100%;height: 100%">
                </a>
                <img
                  slot="reference"
                  :src="driverData.pictures.idCardImgF"
                  class="carImg"
                  style="cursor:pointer"
                >
              </el-popover>
              <el-upload
                class="upload-demo"
                :action="UploadUrl()"
                :headers="header"
                :show-file-list="false"
                :on-success="handleIdCardImgFSuccess"
                :before-upload="beforeAvatarUpload"
              >
                <el-button size="small" type="primary">点击上传</el-button>
              </el-upload>
            </div>
          </el-collapse-item>
          <el-collapse-item>
            <template slot="title">
              驾驶证 (
              <p v-if="driverData.licenceAuthState==1">已认证</p>
              <p v-else>未认证</p>)
            </template>
            <div>
              <el-popover
                v-if="driverData.pictures.drivingImg"
                placement="top-start"
                trigger="click"
              >
                <a :href="driverData.pictures.drivingImg" target="_blank" title="查看最大化图片">
                  <img :src="driverData.pictures.drivingImg" style="width: 100%;height: 100%">
                </a>
                <img
                  slot="reference"
                  :src="driverData.pictures.drivingImg"
                  class="carImg"
                  style="cursor:pointer"
                >
              </el-popover>
              <el-upload
                class="upload-demo"
                :action="UploadUrl()"
                :headers="header"
                :show-file-list="false"
                :on-success="handleDrivingImgSuccess"
                :before-upload="beforeAvatarUpload"
              >
                <el-button size="small" type="primary">点击上传</el-button>
              </el-upload>
            </div>
          </el-collapse-item>
          <el-collapse-item>
            <template slot="title">
              行驶证 (
              <p v-if="driverData.licenceAuthState==1">已认证</p>
              <p v-else>未认证</p>)
            </template>
            <div>
              <el-popover
                v-if="driverData.pictures.patenteImg"
                placement="top-start"
                trigger="click"
              >
                <a :href="driverData.pictures.patenteImg" target="_blank" title="查看最大化图片">
                  <img :src="driverData.pictures.patenteImg" style="width: 100%;height: 100%">
                </a>
                <img
                  slot="reference"
                  :src="driverData.pictures.patenteImg"
                  class="carImg"
                  style="cursor:pointer"
                >
              </el-popover>
              <el-upload
                class="upload-demo"
                :action="UploadUrl()"
                :headers="header"
                :show-file-list="false"
                :on-success="handlePatenteImgSuccess"
                :before-upload="beforeAvatarUpload"
              >
                <el-button size="small" type="primary">点击上传</el-button>
              </el-upload>
            </div>
          </el-collapse-item>
          <el-collapse-item>
            <template slot="title">
              从业资格证 (
              <p v-if="driverData.jobAuthState==1">已认证</p>
              <p v-else>未认证</p>)
            </template>
            <div>
              <el-popover v-if="driverData.pictures.jobImg" placement="top-start" trigger="click">
                <a :href="driverData.pictures.jobImg" target="_blank" title="查看最大化图片">
                  <img :src="driverData.pictures.jobImg" style="width: 100%;height: 100%">
                </a>
                <img
                  slot="reference"
                  :src="driverData.pictures.jobImg"
                  class="carImg"
                  style="cursor:pointer"
                >
              </el-popover>
              <el-upload
                class="upload-demo"
                :action="UploadUrl()"
                :headers="header"
                :show-file-list="false"
                :on-success="handleJobImgSuccess"
                :before-upload="beforeAvatarUpload"
              >
                <el-button size="small" type="primary">点击上传</el-button>
              </el-upload>
            </div>
          </el-collapse-item>
          <el-collapse-item>
            <template slot="title">
              挂靠公司 (
              <p v-if="driverData.attachAuthState==1">已认证</p>
              <p v-else>未认证</p>)
            </template>
            <div>
              <el-popover v-if="driverData.pictures.intoImg" placement="top-start" trigger="click">
                <a :href="driverData.pictures.intoImg" target="_blank" title="查看最大化图片">
                  <img :src="driverData.pictures.intoImg" style="width: 100%;height: 100%">
                </a>
                <img
                  slot="reference"
                  :src="driverData.pictures.intoImg"
                  class="carImg"
                  style="cursor:pointer"
                >
              </el-popover>
              <el-upload
                class="upload-demo"
                :action="UploadUrl()"
                :headers="header"
                :show-file-list="false"
                :on-success="handleIntoImgSuccess"
                :before-upload="beforeAvatarUpload"
              >
                <el-button size="small" type="primary">点击上传</el-button>
              </el-upload>
            </div>
          </el-collapse-item>
        </el-collapse>
      </div>

      <div>
        <aside>订单信息</aside>
      </div>
      <el-table :data="gridData">
        <el-table-column property="orderNo" label="订单编号" width="150" />
        <el-table-column property="createTime" label="订单时间" width="200">
          <template slot-scope="{row}">
            <span>{{ row.createTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
          </template>
        </el-table-column>
        <el-table-column property="userIdNo" label="客户账号" />
        <el-table-column property="orderAmount" label="订单金额" />
        <el-table-column property="payType" label="支付方式" />
        <el-table-column label="状态">
          <template slot-scope="{row}">
            <span>{{ row.state | orderState(row.state) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="{row}">
            <el-button size="mini" @click="orderDetial(row.id)">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="gridListTotal.totalRow>0"
        :total="gridListTotal.totalRow"
        :page.sync="gridListTotal.pageNum"
        :limt.sync="gridListTotal.pageSize"
        @pagination="getList"
      />

      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogTableVisible = false">关闭</el-button>
        <el-button type="primary" @click="updateData()">确认</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" top="10px">
      <el-form
        ref="dataForm"
        :rules="rules"
        :model="temp1"
        label-position="left"
        label-width="140px"
      >
        <el-row :gutter="40">
          <el-col :span="12">
            <el-form-item label="姓名" prop="name">
              <el-input v-model="temp1.name" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="手机号码" prop="phone">
              <el-input v-model="temp1.phone" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="真实姓名" prop="realName">
              <el-input v-model="temp1.idInfo.realName" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="身份证号码">
              <el-input v-model="temp1.idInfo.idCard" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车辆高度" prop="vehicleHeight">
              <el-input v-model="temp1.vehicleInfo.vehicleHeight" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="车辆宽度" prop="name">
              <el-input v-model="temp1.vehicleInfo.vehicleWidth" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车辆长度" prop="vehicleLength">
              <el-input v-model="temp1.vehicleInfo.vehicleLength" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="车辆载重" prop="vehicleLoad">
              <el-input v-model="temp1.vehicleInfo.vehicleLoad" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="车辆类型" prop="vehicleModel">
              <el-select v-model="temp1.vehicleInfo.vehicleModel" class="filter-item" placeholder="请选择">
                <el-option v-for="item in level7" :key="item.key" :label="item.content" :value="item.content" />
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="车辆体积" prop="vehicleVolume">
              <el-input v-model="temp1.vehicleInfo.vehicleVolume" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="车牌号码" prop="vehicleNo">
              <el-input v-model="temp1.vehicleNoInfo.vehicleNo" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="驾驶年龄" prop="driverAge">
              <el-input v-model="temp1.driverAge" />
            </el-form-item>
          </el-col>

        </el-row>
        <el-row :gutter="40">
          <el-col :span="12">

            <el-form-item label="身份证正面照片">
              <div style="display: flex;">
                <el-popover v-if="shouImage.idInfo.frontImg" placement="top-start" trigger="click">
                  <a :href="shouImage.idInfo.frontImg" target="_blank" title="查看最大化图片">
                    <img :src="shouImage.idInfo.frontImg" style="width: 100%;height: 100%">
                  </a>
                  <img
                    slot="reference"
                    :src="shouImage.idInfo.frontImg"
                    class="carImg"
                    style="cursor:pointer"
                  >
                </el-popover>
                <el-upload
                  class="upload-demo"
                  :action="UploadUrl()"
                  :headers="header"
                  :show-file-list="false"
                  :on-success="handIdinfoFrontSuccess"
                  :before-upload="beforeAvatarUpload"
                >
                  <el-button size="small" type="primary">点击上传</el-button>
                </el-upload>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="身份证反面照片">
              <div style="display: flex;">
                <el-popover v-if="shouImage.idInfo.reverseImg" placement="top-start" trigger="click">
                  <a :href="shouImage.idInfo.reverseImg" target="_blank" title="查看最大化图片">
                    <img :src="shouImage.idInfo.reverseImg" style="width: 100%;height: 100%">
                  </a>
                  <img
                    slot="reference"
                    :src="shouImage.idInfo.reverseImg"
                    class="carImg"
                    style="cursor:pointer"
                  >
                </el-popover>
                <el-upload
                  class="upload-demo"
                  :action="UploadUrl()"
                  :headers="header"
                  :show-file-list="false"
                  :on-success="handIdinfoReverseSuccess"
                  :before-upload="beforeAvatarUpload"
                >
                  <el-button size="small" type="primary">点击上传</el-button>
                </el-upload>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="驾驶证照片">
              <div style="display: flex;">
                <el-popover v-if="shouImage.licenseInfo.drivingImg" placement="top-start" trigger="click">
                  <a :href="shouImage.licenseInfo.drivingImg" target="_blank" title="查看最大化图片">
                    <img :src="shouImage.licenseInfo.drivingImg" style="width: 100%;height: 100%">
                  </a>
                  <img
                    slot="reference"
                    :src="shouImage.licenseInfo.drivingImg"
                    class="carImg"
                    style="cursor:pointer"
                  >
                </el-popover>
                <el-upload
                  class="upload-demo"
                  :action="UploadUrl()"
                  :headers="header"
                  :show-file-list="false"
                  :on-success="handlicenseInfoDrivingImgSuccess"
                  :before-upload="beforeAvatarUpload"
                >
                  <el-button size="small" type="primary">点击上传</el-button>
                </el-upload>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="行驶证照片">
              <div style="display: flex;">
                <el-popover v-if="shouImage.licenseInfo.patenteImg" placement="top-start" trigger="click">
                  <a :href="shouImage.licenseInfo.patenteImg" target="_blank" title="查看最大化图片">
                    <img :src="shouImage.licenseInfo.patenteImg" style="width: 100%;height: 100%">
                  </a>
                  <img
                    slot="reference"
                    :src="shouImage.licenseInfo.patenteImg"
                    class="carImg"
                    style="cursor:pointer"
                  >
                </el-popover>
                <el-upload
                  class="upload-demo"
                  :action="UploadUrl()"
                  :headers="header"
                  :show-file-list="false"
                  :on-success="handlicenseInfoPatenteImgSuccess"
                  :before-upload="beforeAvatarUpload"
                >
                  <el-button size="small" type="primary">点击上传</el-button>
                </el-upload>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车辆正面照片">
              <div style="display: flex;">
                <el-popover v-if="shouImage.vehicleInfo.frontImg" placement="top-start" trigger="click">
                  <a :href="shouImage.vehicleInfo.frontImg" target="_blank" title="查看最大化图片">
                    <img :src="shouImage.vehicleInfo.frontImg" style="width: 100%;height: 100%">
                  </a>
                  <img
                    slot="reference"
                    :src="shouImage.vehicleInfo.frontImg"
                    class="carImg"
                    style="cursor:pointer"
                  >
                </el-popover>
                <el-upload
                  class="upload-demo"
                  :action="UploadUrl()"
                  :headers="header"
                  :show-file-list="false"
                  :on-success="handvehicleInfoFrontImgSuccess"
                  :before-upload="beforeAvatarUpload"
                >
                  <el-button size="small" type="primary">点击上传</el-button>
                </el-upload>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车辆背面照片">
              <div style="display: flex;">
                <el-popover v-if="shouImage.vehicleInfo.reverseImg" placement="top-start" trigger="click">
                  <a :href="shouImage.vehicleInfo.reverseImg" target="_blank" title="查看最大化图片">
                    <img :src="shouImage.vehicleInfo.reverseImg" style="width: 100%;height: 100%">
                  </a>
                  <img
                    slot="reference"
                    :src="shouImage.vehicleInfo.reverseImg"
                    class="carImg"
                    style="cursor:pointer"
                  >
                </el-popover>
                <el-upload
                  class="upload-demo"
                  :action="UploadUrl()"
                  :headers="header"
                  :show-file-list="false"
                  :on-success="handvehicleInfoReverseImgSuccess"
                  :before-upload="beforeAvatarUpload"
                >
                  <el-button size="small" type="primary">点击上传</el-button>
                </el-upload>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车辆左侧照片">
              <div style="display: flex;">
                <el-popover v-if="shouImage.vehicleInfo.leftImg" placement="top-start" trigger="click">
                  <a :href="shouImage.vehicleInfo.leftImg" target="_blank" title="查看最大化图片">
                    <img :src="shouImage.vehicleInfo.leftImg" style="width: 100%;height: 100%">
                  </a>
                  <img
                    slot="reference"
                    :src="shouImage.vehicleInfo.leftImg"
                    class="carImg"
                    style="cursor:pointer"
                  >
                </el-popover>
                <el-upload
                  class="upload-demo"
                  :action="UploadUrl()"
                  :headers="header"
                  :show-file-list="false"
                  :on-success="handvehicleInfoLeftImgSuccess"
                  :before-upload="beforeAvatarUpload"
                >
                  <el-button size="small" type="primary">点击上传</el-button>
                </el-upload>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车辆右侧照片">
              <div style="display: flex;">
                <el-popover v-if="shouImage.vehicleInfo.rightImg" placement="top-start" trigger="click">
                  <a :href="shouImage.vehicleInfo.rightImg" target="_blank" title="查看最大化图片">
                    <img :src="shouImage.vehicleInfo.rightImg" style="width: 100%;height: 100%">
                  </a>
                  <img
                    slot="reference"
                    :src="shouImage.vehicleInfo.rightImg"
                    class="carImg"
                    style="cursor:pointer"
                  >
                </el-popover>
                <el-upload
                  class="upload-demo"
                  :action="UploadUrl()"
                  :headers="header"
                  :show-file-list="false"
                  :on-success="handvehicleInfoRightImgSuccess"
                  :before-upload="beforeAvatarUpload"
                >
                  <el-button size="small" type="primary">点击上传</el-button>
                </el-upload>
              </div>
            </el-form-item>
          </el-col>
        </el-row>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取消</el-button>
        <el-button type="primary" @click="createData">确认</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="dialogPvVisible" title="Reading statistics">
      <el-table :data="pvData" border fit highlight-current-row style="width: 100%">
        <el-table-column prop="key" label="Channel" />
        <el-table-column prop="pv" label="Pv" />
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogPvVisible = false">Confirm</el-button>
      </span>
    </el-dialog>

    <el-dialog title="查看详情" :visible.sync="dialogFormVisible1">
      <el-form
        ref="dataForm"
        :model="temp"
        label-position="right"
        label-width="150px"
        style="width: 400px; margin-left:50px;"
      >
        <el-form-item label="订单预计装货时间">
          <el-date-picker
            v-model="temp.shipmentTime.start"
            readonly
            :picker-options="pickerOptions0"
            placeholder="选择日期"
            type="datetime"
            value-format="timestamp"
            format="yyyy-MM-dd HH 时"
          />
          <!-- <el-time-select
            v-model="shipmentTime.time"
            align="center"
            :picker-options="{
              start: '00:00',
              step: '01:00',
              end: '24:00'
            }"
            placeholder="选择时间"
            @change="changeTime"
          />-->
          <!-- <el-date-picker v-model="temp.shipmentTime.start" type="datetime" placeholder="Please pick a date" /> -->
        </el-form-item>
        <!-- <el-form-item label="订单接单最晚时间" prop="timestamp">
          <el-date-picker v-model="temp.shipmentTime.end" type="datetime" placeholder="Please pick a date" />
        </el-form-item>-->
        <el-form-item label="订单预计送达时间">
          <el-date-picker
            v-model="temp.arrivalTime.start"
            readonly
            :picker-options="pickerOptions0"
            placeholder="选择日期"
            type="datetime"
            value-format="timestamp"
            format="yyyy-MM-dd HH 时"
          />
          <!-- <el-date-picker v-model="temp.arrivalTime.start" type="datetime" placeholder="Please pick a date" /> -->
        </el-form-item>
        <!-- <el-form-item label="订单预计送达最晚时间" prop="timestamp">
          <el-date-picker v-model="temp.arrivalTime.end" type="datetime" placeholder="Please pick a date" />
        </el-form-item>-->

        <el-form-item label="货物名称">
          <el-input v-model="temp.freightName" placeholder="请输入货物名称" readonly />
        </el-form-item>
        <el-form-item label="货物最小重量">
          <el-input v-model="temp.freightWeight.min" placeholder="货物最小重量" readonly />吨
        </el-form-item>
        <el-form-item label="货物最大重量">
          <el-input v-model="temp.freightWeight.max" placeholder="货物最大重量" readonly />吨
        </el-form-item>

        <el-form-item label="货物最小体积">
          <el-input v-model="temp.freightBulk.min" placeholder="货物最小体积" readonly />方
        </el-form-item>
        <el-form-item label="货物最大体积">
          <el-input v-model="temp.freightBulk.max" placeholder="货物最大体积" readonly />方
        </el-form-item>
        <el-form-item label="出发地地址">
          <el-input v-model="temp.from.city" placeholder="详细地址" readonly />
          <el-input v-model="temp.from.address" placeholder="详细地址" readonly />
        </el-form-item>
        <el-form-item label="收货地地址">
          <el-input v-model="temp.to.city" placeholder="详细地址" readonly />
          <el-input v-model="temp.to.address" placeholder="详细地址" readonly />
        </el-form-item>

        <el-form-item label="用车类型">
          <el-input v-model="temp.useVehicleType" placeholder="请输入用车类型" readonly />
        </el-form-item>
        <el-form-item label="车长">
          <el-input v-model="temp.vehicleLen" placeholder="请输入车长" readonly />
        </el-form-item>
        <el-form-item label="车型">
          <el-input v-model="temp.vehicleModel" placeholder="请输入车型" readonly />
        </el-form-item>
        <el-form-item label="几装几卸">
          <el-input v-model="temp.hand" placeholder="请输入装卸次数" readonly />
        </el-form-item>

        <el-form-item label="特殊要求">
          <el-input v-model="temp.specialAsk" placeholder="请输入特殊要求" readonly />
        </el-form-item>
        <el-form-item label="备注">
          <el-input v-model="temp.remarks" placeholder="请输入备注" readonly />
        </el-form-item>
        <el-form-item label="运费">
          <el-input v-model="temp.freight" placeholder="Please input" readonly />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible1 = false">关闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  fetchList,
  fetchPv,
  createArticle,
  updateArticle,
  getTotal,
  searchList,
  stopCar,
  backCar,
  getDriverDetail,
  getDriverOrderList,
  addPic
  // createObjectURL
} from '@/api/driver'
import { getSetting } from '@/api/order'

import { getDetail } from '@/api/order'
import waves from '@/directive/waves' // waves directive
import { parseTime } from '@/utils'
import { getToken } from '@/utils/auth'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import '../../styles/car.scss'
const calendarTypeOptions = [
  { key: 'CN', display_name: 'China' },
  { key: 'US', display_name: 'USA' },
  { key: 'JP', display_name: 'Japan' },
  { key: 'EU', display_name: 'Eurozone' }
]

// arr to obj, such as { CN : "China", US : "USA" }
const calendarTypeKeyValue = calendarTypeOptions.reduce((acc, cur) => {
  acc[cur.key] = cur.display_name
  return acc
}, {})

const orderStateDate = []
orderStateDate[-1] = '货主取消订单'
orderStateDate[-2] = '货主申请取消订单'
orderStateDate[-4] = '司机取消订单'
orderStateDate[0] = '待接货'
orderStateDate[1] = '已接单'
orderStateDate[2] = '已装货'
orderStateDate[3] = '待发货'
orderStateDate[4] = '待收货'
orderStateDate[5] = '已达到'
orderStateDate[6] = '已完成'

export default {
  name: 'ComplexTable',
  components: { Pagination },
  directives: { waves },
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: 'success',
        draft: 'info',
        deleted: 'danger'
      }
      return statusMap[status]
    },
    typeFilter(type) {
      return calendarTypeKeyValue[type]
    },
    parseTime: parseTime,
    orderState(type) {
      return orderStateDate[type]
    },
    usertype(type) {
      const usertype = []
      usertype[1] = '司机'
      usertype[2] = '货主'
      return usertype[type]
    }
  },
  data() {
    return {
      pickerOptions0: {
        disabledDate: time => {
          return time.getTime() <= Date.now() - 8.64e7
        }
      },
      header: {
        consumes: 'multipart/form-data',
        token: getToken()
      },
      userId: null,
      objectBind: null,
      dialogTableVisible: false,
      tableKey: 0,
      list: null,
      carTotal: {
        total: 0,
        chauffeurBusy: 0,
        chauffeurOnline: 0,
        chauffeurStopped: 0
      },
      total: 0,
      listLoading: true,
      listQuery: {
        pageNum: 1,
        pageSize: 20,
        importance: undefined,
        title: undefined,
        state: undefined,
        orderId: undefined,
        driverName: undefined

        // sort: '+id'
      },
      search: {
        number: '',
        pageNum: 1,
        pageSize: 20
      },
      importanceOptions: [1, 2, 3],
      calendarTypeOptions,
      sortOptions: [
        { label: 'ID Ascending', key: '+id' },
        { label: 'ID Descending', key: '-id' }
      ],
      statusOptions: ['published', 'draft', 'deleted'],
      showReviewer: false,
      temp1: {
        phone: null,
        name: '',
        driverAge: '',
        idInfo: {
          frontImg: 0,
          idCard: '',
          realName: '',
          reverseImg: 0
        },
        licenseInfo: {
          drivingImg: 0,
          patenteImg: 0
        },
        vehicleInfo: {
          frontImg: 0,
          leftImg: 0,
          reverseImg: 0,
          rightImg: 0,
          vehicleHeight: 0,
          vehicleLength: 0,
          vehicleLoad: 0,
          vehicleModel: '',
          vehicleVolume: 0,
          vehicleWidth: 0
        },
        vehicleNoInfo: {
          vehicleImg: 0,
          vehicleNo: ''
        }
      },
      temp: {
        arrivalTime: {
          end: new Date(),
          start: new Date()
        },
        freight: 0,
        freightBulk: {
          max: 1,
          min: 1
        },
        freightName: '',
        freightWeight: {
          max: 1,
          min: 1
        },
        from: {
          address: '',
          city: [],
          province: ''
        },
        hand: '',
        remarks: '',
        shipmentTime: {
          end: new Date(),
          start: new Date()
        },
        specialAsk: [],
        to: {
          address: '',
          city: [],
          province: ''
        },
        useVehicleType: '',
        vehicleLen: '',
        vehicleModel: ''
      },
      dialogFormVisible: false,
      dialogFormVisible1: false,
      dialogStatus: '',
      textMap: {
        update: 'Edit',
        create: 'Create'
      },
      dialogPvVisible: false,
      pvData: [],
      rules: {
        type: [
          { required: true, message: 'type is required', trigger: 'change' }
        ],
        timestamp: [
          {
            type: 'date',
            required: true,
            message: 'timestamp is required',
            trigger: 'change'
          }
        ],
        title: [
          { required: true, message: 'title is required', trigger: 'blur' }
        ]
      },
      downloadLoading: false,
      gridData: [],
      gridListTotal: {
        pageNum: 1,
        pageSize: 20,
        totalRow: 0
      },
      driverData: {
        attachAuthState: '',
        idAuthState: '',
        jobAuthState: '',
        licenceAuthState: '',
        pictures: {
          intoImg: '',
          jobImg: '',
          patenteImg: '',
          drivingImg: '',
          idCardImgF: '',
          idCardImgB: '',
          leftImg: '',
          reverseImg: '',
          rightImg: '',
          vehicleImg: ''
        }
      },
      shouImage: {
        idInfo: {
          frontImg: '',
          reverseImg: ''
        },
        licenseInfo: {
          drivingImg: '',
          patenteImg: ''
        },
        vehicleInfo: {
          frontImg: '',
          leftImg: '',
          reverseImg: '',
          rightImg: ''
        },
        vehicleNoInfo: {
          vehicleImg: ''
        }
      },
      editDriver: {
        headImg: ''
      },
      driverTotalData: [
        {
          income: 0,
          orderTotal: 0,
          commentTotal: 0
        }
      ],
      level7: []

    }
  },
  created() {
    this.getTotal()
    this.getList()
    this.getOption()
  },
  methods: {

    getOption() {
      getSetting().then(response => {
        this.level7 = response.result[4].infos
        this.$forceUpdate()
        // Just to simulate the time of the request
        // setTimeout(() => {
        //   this.listLoading = false
        // }, 1.5 * 1000)
      })
    },
    UploadUrl() {
      // var url="/web/file/img/upload/"
      var url = 'https://www.gdhtc.cn//web/file/img/upload/'
      return url
    },
    getList() {
      this.listLoading = true
      fetchList(this.listQuery).then(response => {
        console.log(response.result)
        this.list = response.result
        this.total = response.page.totalRow

        // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    },
    getTotal() {
      this.listLoading = true
      getTotal().then(response => {
        this.carTotal = response.result
        // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    },
    handleFilter(typeDate) {
      if (!isNaN(typeDate)) {
        console.log('sss' + typeDate)
        this.listQuery.state = typeDate
      } else {
        console.log(typeDate)
        this.listQuery.state = ''
      }
      const arr = this.listQuery
      for (const key in arr) {
        // 去除对象内多余的空值key
        if (arr[key] === '') {
          delete arr[key]
        }
      }
      this.listQuery = arr
      this.listQuery.pageNum = 1
      this.getList()
    },
    // 搜索更新列表
    searchList() {
      this.listLoading = true
      searchList(this.search).then(response => {
        console.log(response.result)
        this.list = response.result
        this.total = response.page.totalRow

        // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    },
    handleModifyStatus(row, status) {
      this.$message({
        message: '操作Success',
        type: 'success'
      })
      row.status = status
    },
    openDetail(id) {
      console.log(id)
      // var dialogTableVisible = !this.dialogTableVisible
      this.userId = id
      this.dialogTableVisible = !this.dialogTableVisible
      getDriverDetail(id).then(response => {
        this.driverData = response.result
        this.editDriver = response.result
        this.driverTotalData[0].income = response.result.income
        this.driverTotalData[0].orderTotal = response.result.orderTotal
        this.driverTotalData[0].commentTotal = response.result.commentTotal
        this.getDriverOrderList(id)
        console.log(this.driverTotalData)
        console.log(response)
      })
    },
    getDriverOrderList(id) {
      getDriverOrderList(id).then(response2 => {
        console.log(response2)
        this.gridData = response2.result
        this.gridListTotal = response2.page
      })
      console.log(this.gridListTotal)
    },
    stopCar(id) {
      this.listLoading = true

      stopCar(id).then(response => {
        console.log(response.result)
        this.getTotal()
        this.getList()

        // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    },

    backCar(id) {
      this.listLoading = true
      backCar(id).then(response => {
        console.log(response.result)
        this.getTotal()
        this.getList()

        // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    },
    sortChange(data) {
      const { prop, order } = data
      if (prop === 'id') {
        this.sortByID(order)
      }
    },
    sortByID(order) {
      if (order === 'ascending') {
        this.listQuery.sort = '+id'
      } else {
        this.listQuery.sort = '-id'
      }
      this.handleFilter()
    },
    resetTemp() {
      this.temp1 = {
        driverAge: '',
        phone: null,
        name: '',
        idInfo: {
          frontImg: 0,
          idCard: '',
          realName: '',
          reverseImg: 0
        },
        licenseInfo: {
          drivingImg: 0,
          patenteImg: 0
        },
        vehicleInfo: {
          frontImg: 0,
          leftImg: 0,
          reverseImg: 0,
          rightImg: 0,
          vehicleHeight: 0,
          vehicleLength: 0,
          vehicleLoad: 0,
          vehicleModel: '',
          vehicleVolume: 0,
          vehicleWidth: 0
        },
        vehicleNoInfo: {
          vehicleImg: 0,
          vehicleNo: ''
        }
      }
      this.shouImage = {
        idInfo: {
          frontImg: '',
          reverseImg: ''
        },
        licenseInfo: {
          drivingImg: '',
          patenteImg: ''
        },
        vehicleInfo: {
          frontImg: '',
          leftImg: '',
          reverseImg: '',
          rightImg: ''
        },
        vehicleNoInfo: {
          vehicleImg: ''
        }
      }
    },
    handleCreate() {
      this.resetTemp()
      this.dialogStatus = '新增'
      this.dialogFormVisible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].clearValidate()
      })
    },
    createData() {
      this.$refs['dataForm'].validate(valid => {
        if (valid) {
          createArticle(this.temp1).then(() => {
            // this.list.unshift(this.temp)
            this.dialogFormVisible = false
            this.getList()
            this.$notify({
              title: '成功',
              message: '创建成功',
              type: 'success',
              duration: 2000
            })
          })
        }
      })
    },
    updateData() {
      console.log(this.editDriver)
      // if (this.editDriver.headImg1) {
      //   this.editDriver.headImg = parseInt(this.editDriver.headImg1)
      // }
      // if (this.editDriver.idCardImgF1) {
      //   this.editDriver.idCardImgF = parseInt(this.editDriver.idCardImgF1)
      // }
      // if (this.editDriver.idCardImgB1) {
      //   this.editDriver.idCardImgB = parseInt(this.editDriver.idCardImgB1)
      // }
      updateArticle(this.editDriver).then(response => {
        this.$notify({
          title: '编辑成功',
          message: '编辑成功',
          type: 'success',
          duration: 2000
        })
        this.dialogTableVisible = false
        this.getTotal()
        this.getList()
      })
    },
    handleDelete(row) {
      this.$notify({
        title: 'Success',
        message: 'Delete Successfully',
        type: 'success',
        duration: 2000
      })
      const index = this.list.indexOf(row)
      this.list.splice(index, 1)
    },
    handleFetchPv(pv) {
      fetchPv(pv).then(response => {
        this.pvData = response.data.pvData
        this.dialogPvVisible = true
      })
    },
    handleDownload() {
      this.downloadLoading = true
      import('@/vendor/Export2Excel').then(excel => {
        const tHeader = [
          'timestamp',
          'orderNo',
          'type',
          'importance',
          'status'
        ]
        const filterVal = [
          'timestamp',
          'orderNo',
          'type',
          'importance',
          'status'
        ]
        const data = this.formatJson(filterVal, this.list)
        excel.export_json_to_excel({
          header: tHeader,
          data,
          filename: 'table-list'
        })
        this.downloadLoading = false
      })
    },
    formatJson(filterVal, jsonData) {
      return jsonData.map(v =>
        filterVal.map(j => {
          if (j === 'timestamp') {
            return parseTime(v[j])
          } else {
            return v[j]
          }
        })
      )
    },
    getSortClass: function(key) {
      const sort = this.listQuery.sort
      return sort === `+${key}`
        ? 'ascending'
        : sort === `-${key}`
          ? 'descending'
          : ''
    },
    handleAvatarSuccess(res, file) {
      // this.editDriver.headImg1 = res.result.id
      console.log(this.editDriver)
      this.driverData.headImg = res.result.fileUrl
      this.editDriver.headImg = res.result.fileUrl
      // this.imageUrl = createObjectURL(file.raw)
    },
    handleIdCardImgBSuccess(res, file) {
      // this.editDriver.pictures.idCardImgB1 = res.result.id
      console.log(this.editDriver)
      if (!this.driverData.pictures.idCardImgB) {
        var param = {
          state: 1,
          userId: this.userId,
          idInfo: {
            idCardImgB: res.result.id
          }
        }
        addPic(param).then(res => {
          console.log(res)
        })
      }
      this.driverData.pictures.idCardImgB = res.result.fileUrl
      this.editDriver.pictures.idCardImgB = res.result.fileUrl
      // this.imageUrl = createObjectURL(file.raw)
    },
    handleIdCardImgFSuccess(res, file) {
      // this.editDriver.pictures.idCardImgF1 = res.result.id
      console.log(this.editDriver)
      if (!this.driverData.pictures.idCardImgF) {
        var param = {
          state: 1,
          userId: this.userId,
          idInfo: {
            idCardImgF: res.result.id
          }
        }
        addPic(param).then(res => {
          console.log(res)
        })
      }
      this.driverData.pictures.idCardImgF = res.result.fileUrl
      this.editDriver.pictures.idCardImgF = res.result.fileUrl
      // this.imageUrl = createObjectURL(file.raw)
    },
    handleDrivingImgSuccess(res, file) {
      console.log(this.editDriver)
      if (!this.driverData.pictures.patenteImg) {
        var param = {
          state: 1,
          userId: this.userId,
          licenceInfo: {
            drivingImg: res.result.id
          }
        }
        addPic(param).then(res => {
          console.log(res)
        })
      }
      this.driverData.pictures.idCardImgF = res.result.fileUrl
      this.editDriver.pictures.idCardImgF = res.result.fileUrl
    },
    handlePatenteImgSuccess(res, file) {
      console.log(this.editDriver)
      if (!this.driverData.pictures.patenteImg) {
        var param = {
          state: 1,
          userId: this.userId,
          licenceInfo: {
            patenteImg: res.result.id
          }
        }
        addPic(param).then(res => {
          console.log(res)
        })
      }
      this.driverData.pictures.patenteImg = res.result.fileUrl
      this.editDriver.pictures.patenteImg = res.result.fileUrl
    },
    handleJobImgSuccess(res, file) {
      console.log(this.editDriver)
      if (!this.driverData.pictures.intoImg) {
        var param = {
          state: 1,
          userId: this.userId,
          jobInfo: {
            jobImg: res.result.id
          }
        }
        addPic(param).then(res => {
          console.log(res)
        })
      }
      this.driverData.pictures.jobImg = res.result.fileUrl
      this.editDriver.pictures.jobImg = res.result.fileUrl
    },
    handleIntoImgSuccess(res, file) {
      console.log(this.editDriver)
      if (!this.driverData.pictures.intoImg) {
        var param = {
          state: 1,
          userId: this.userId,
          attachInfo: {
            intoImg: res.result.id,
            companyName: ''
          }
        }
        addPic(param).then(res => {
          console.log(res)
        })
      }
      this.driverData.pictures.intoImg = res.result.fileUrl
      this.editDriver.pictures.intoImg = res.result.fileUrl
    },

    // 新建

    handIdinfoFrontSuccess(res, file) {
      this.temp1.idInfo.frontImg = res.result.id
      this.shouImage.idInfo.frontImg = res.result.fileUrl
    },

    handIdinfoReverseSuccess(res, file) {
      this.temp1.idInfo.reverseImg = res.result.id
      this.shouImage.idInfo.reverseImg = res.result.fileUrl
    },
    handlicenseInfoDrivingImgSuccess(res, file) {
      this.temp1.licenseInfo.drivingImg = res.result.id
      this.shouImage.licenseInfo.drivingImg = res.result.fileUrl
    },
    handlicenseInfoPatenteImgSuccess(res, file) {
      this.temp1.licenseInfo.patenteImg = res.result.id
      this.shouImage.licenseInfo.patenteImg = res.result.fileUrl
    },
    handvehicleInfoFrontImgSuccess(res, file) {
      this.temp1.vehicleInfo.frontImg = res.result.id
      this.temp1.vehicleNoInfo.vehicleImg = res.result.id
      this.shouImage.vehicleInfo.frontImg = res.result.fileUrl
    },
    handvehicleInfoReverseImgSuccess(res, file) {
      this.temp1.vehicleInfo.reverseImg = res.result.id
      this.shouImage.vehicleInfo.reverseImg = res.result.fileUrl
    },
    handvehicleInfoLeftImgSuccess(res, file) {
      this.temp1.vehicleInfo.leftImg = res.result.id
      this.shouImage.vehicleInfo.leftImg = res.result.fileUrl
    },
    handvehicleInfoRightImgSuccess(res, file) {
      this.temp1.vehicleInfo.rightImg = res.result.id
      this.shouImage.vehicleInfo.rightImg = res.result.fileUrl
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === 'image/jpeg' || 'image/png'
      const isLt2M = file.size / 1024 / 1024 < 2
      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 或 PNG 格式!')
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 2MB!')
      }
      return isJPG && isLt2M
    },

    orderDetial(id) {
      this.dialogFormVisible1 = !this.dialogFormVisible1
      getDetail(id).then(response => {
        this.temp = response.result
        this.temp.shipmentTime.start = this.temp.shipmentTime.start * 1000
        this.temp.arrivalTime.start = this.temp.arrivalTime.start * 1000
        this.temp.specialAsk = this.temp.specialAsk.toString()
        console.log(this.temp)
        this.dialogFormVisible1 = true
      })
    }
  }
}
</script>
<style>
.tableTitle {
  width: 150px;
  padding-right: 20px;
  text-align: right;
  font-weight: bold;
}
.authTable tr {
  height: 50px;
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 100px;
  display: block;
}
</style>
